<template>
    <div class="underline signs" @click="openDialog">
        <img v-if="imgUrl" :src="imgUrl" class="signs_img" alt="签名">
    </div>
    <el-dialog v-model="dialogVisible" :title="label" width="650px">
        <!-- 添加包裹层并使用 Flex 布局实现居中 -->
        <div class="dialog-content-center">
            <SignTemblate
                    :resultImg="imgUrl"
                    :currentSignType="signType"
                    @updateSignImg="handleUpdateSignImg"
            />
        </div>
    </el-dialog>
</template>

<script>
    import SignTemblate from "../SignTemblate";

    export default {
        name: "SignatureField",
        components: {
            SignTemblate
        },
        props: {
            label: String,
            signType: String,
            imgUrl: String
        },
        data() {
            return {
                dialogVisible: false
            };
        },
        methods: {
            openDialog() {
                this.dialogVisible = true;
            },
            handleUpdateSignImg(sign) {
                this.$emit('update:imgUrl', sign);
                this.dialogVisible = false;
            }
        }
    };
</script>

<style scoped>
    /* 添加居中样式 */
    .dialog-content-center {
        display: flex;
        justify-content: center; /* 水平居中 */
        align-items: center;     /* 垂直居中 */
    }
    :deep(.el-button) {
        right: 0;
    }
</style>
